﻿@model SLSYJ.Controllers.DTOs.EmployeeDTO
@using SLSYJ.Controllers.Helpers

@{
    this.Layout = null;
}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Common.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/fileuploader.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Validations.js")" type="text/javascript"></script>
<link href="@Url.Content("~/Content/themes/ui.jqgrid.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/themes/base/jquery.ui.dialog.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/themes/base/fileuploader.css")" rel="stylesheet" type="text/css" />

<script type="text/javascript">
    $(function () {
        $("#dialog").dialog({
            bgiframe: true,
            height: 140,
            modal: true,
            autoOpen: false,
            resizable: false
        })
    });
    $(document).ready(function () {
        var uploader = new qq.FileUploader({
            element: document.getElementById('fileuploader'),
            action: '/SLSYJ/Employees/UploadEmployeeImage',
            allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
            onSubmit: function (id, fileName) {
                $('.qq-upload-list').hide();

                var fileDescription = $('#fileDescriptionSelectList').val()
                if (fileDescription == 'Other')
                    fileDescription = $('#fileDescriptionOther').val();

                uploader.setParams({
                    fileDescription: fileDescription
                });
            },
            onComplete: function (id, fileName, responseJSON) {
                var BaseUrl = 'http://' + top.location.host;
                $('.qq-upload-list').hide();
                $('#profileImage').attr("src", BaseUrl + responseJSON.fileName);
            }
        });
        //collapsible panel management + collapse initially
        $("#collapsibleHeader").toggleClass("collapsibleExpanded", false).click(function () {
            $(this).toggleClass("collapsibleExpanded").next("#collapsibleBody").slideToggle('fast');
        });
        $("#collapsibleBody").hide();
    });
</script>
@using (Html.BeginForm("Edit","Employees"))
{
    @Html.ValidationSummary(true)
    @Html.HiddenFor(model => model.ID)
    <div class="line"></div>
    <article id="article_Edit">
        <div class="line"></div>                  
        <div class="articleBody clear">    
            <table style="width: 100%;border:0;">
                <tr>
                    <td>
                        <fieldset>
                            <legend>Datos personales</legend>
                            <table style="width: 100%;border:0;">
                                <tr>
                                    <td>
                                        <img src="@(String.IsNullOrEmpty(Model.Picture) ? "../../Content/themes/base/images/facebook-no-image1.gif" : Model.Picture)" id="profileImage" alt='' width='150px' height='150px'/><br/>
                                        <div id="fileuploader">
                                            <noscript>
                                                @using (Html.BeginForm("Upload", "Employees", FormMethod.Post, new { enctype = "multipart/form-data" }))
                                                {
                                                    <input type="file" name="photo" id="photo" />   
                                                    <input type="submit" value="Upload" name="submit"/>
                                                }
                                            </noscript>
                                        </div>
                                    </td>
                                    <td>
                                        <table style="width: 100%;border:0;">
                                            <tr>
                                                <td>
                                                    <div class="editor-label">
                                                        @Html.LabelFor(model => model.Name)
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="editor-field">
                                                        @Html.EditorFor(model => model.Name)
                                                        @Html.ValidationMessageFor(model => model.Name)
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <div class="editor-label">
                                                        @Html.LabelFor(model => model.Surname)
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="editor-field">
                                                        @Html.EditorFor(model => model.Surname)
                                                        @Html.ValidationMessageFor(model => model.Surname)
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <div class="editor-label">
                                                        @Html.LabelFor(model => model.DNInumber)
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="editor-field">
                                                        @Html.EditorFor(model => model.DNInumber)
                                                        @Html.ValidationMessageFor(model => model.DNInumber)
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <div class="editor-label">
                                                        @Html.LabelFor(model => model.CUILnumber)
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="editor-field">
                                                        @Html.EditorFor(model => model.CUILnumber)
                                                        @Html.ValidationMessageFor(model => model.CUILnumber)
                                                    </div>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <table>
                                            <tr>
                                                <td>
                                                    <div class="editor-label">
                                                        @Html.LabelFor(model => model.Sex)
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="editor-field">
                                                        @Html.RadioButtonForEnum(x => x.Sex)
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <div class="editor-label">
                                                        @Html.LabelFor(model => model.DateOfBirth)
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="editor-field">
                                                        @Html.TextBox("DateOfBirth", (Model.DateOfBirth.ToShortDateString()), new { @class = "date" })
                                                        @Html.ValidationMessageFor(model => model.DateOfBirth)
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <div class="editor-label">
                                                        @Html.LabelFor(model => model.MaritalStatus)
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="editor-field">
                                                        @Html.RadioButtonForEnum(x => x.MaritalStatus)
                                                    </div>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </fieldset>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="line"></div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <fieldset>
                            <legend>Datos laborales</legend>
                            <table style="width: 100%;border:0;">
                                <tr>
                                    <td>
                                        <table style="width: 100%;border:0;">
                                            <tr>
                                                <td>
                                                    <div class="editor-label">
                                                        @Html.LabelFor(model => model.FileNumber)
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="editor-field">
                                                        @Html.EditorFor(model => model.FileNumber)
                                                        @Html.ValidationMessageFor(model => model.FileNumber)
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <div class="editor-label">
                                                        @Html.LabelFor(model => model.CardNumber)
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="editor-field">
                                                        @Html.EditorFor(model => model.CardNumber)
                                                        @Html.ValidationMessageFor(model => model.CardNumber)
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <div class="editor-label">
                                                        @Html.LabelFor(model => model.HiringDate)
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="editor-field">
                                                        @Html.TextBox("HiringDate", (Model.HiringDate.ToShortDateString()), new { @class = "date" })
                                                        @Html.ValidationMessageFor(model => model.HiringDate)
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <div class="editor-label">
                                                        @Html.LabelFor(model => model.Comments)
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="editor-field">
                                                        @Html.TextAreaFor(model => model.Comments, new { width = 500 })
                                                        @Html.ValidationMessageFor(model => model.Comments)
                                                    </div>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td>
                                        <table style="width: 100%;border:0;">
                                            <tr>
                                                <td>
                                                    <div class="editor-label">
                                                        @Html.LabelFor(model => model.Salary)
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="editor-field">
                                                        @Html.TextBox("Salary", Model.Salary, new { @class = "money" })
                                                        @Html.ValidationMessageFor(model => model.Salary)
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <div class="editor-label">
                                                        @Html.LabelFor(model => model.RemunerativeSalary)
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="editor-field">
                                                        @Html.TextBox("RemunerativeSalary", Model.RemunerativeSalary, new { @class = "money" })
                                                        @Html.ValidationMessageFor(model => model.RemunerativeSalary)
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <div class="editor-label">
                                                        @Html.LabelFor(model => model.NonRemunerativeSalary)
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="editor-field">
                                                        @Html.TextBox("NonRemunerativeSalary", Model.NonRemunerativeSalary, new { @class = "money" })
                                                        @Html.ValidationMessageFor(model => model.NonRemunerativeSalary)
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <div class="editor-label">
                                                        @Html.LabelFor(model => model.HasAgreement)
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="editor-field">
                                                        @Html.EditorFor(model => model.HasAgreement)
                                                        @Html.ValidationMessageFor(model => model.HasAgreement)
                                                    </div>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <div class="line"></div>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <div id="collapsibleHeader" class="collapsibleHeader">
                                            <div class="collapsableBlue">
                                                <label>@Html.LabelFor(model => model.EmployeeBank)</label>
                                            </div>
                                        </div>
	                                    <div id="collapsibleBody" class="collapsableBlack">
                                            <table>
                                                <tr>
                                                    <td>
                                                        <div class="editor-label">
                                                            @Html.LabelFor(model => model.EmployeeBank.Name)
                                                            @Html.EditorFor(model => model.EmployeeBank.Name)
                                                            @Html.ValidationMessageFor(model => model.EmployeeBank.Name)
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="editor-label">
                                                            @Html.LabelFor(model => model.EmployeeBank.AccountNumber)
                                                            @Html.EditorFor(model => model.EmployeeBank.AccountNumber)
                                                            @Html.ValidationMessageFor(model => model.EmployeeBank.AccountNumber)
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="editor-label">
                                                            @Html.LabelFor(model => model.EmployeeBank.CBUNumber)
                                                            @Html.EditorFor(model => model.EmployeeBank.CBUNumber)
                                                        </div>
                                                    </td>
                                                </tr>
                                            </table>
	                                    </div>
                                    </td>
                                </tr>
                            </table>
                        </fieldset>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="line"></div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="submit" value="Guardar" /> | @Html.ActionLink("Volver a la lista", "List")
                        | <a id='close' href='' class='ocultar'>Cerrar</a>
                    </td>
                </tr>
            </table>
        </div>
    </article>
}
